package com.example.literaturesystem.dao.publisher;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import com.example.literaturesystem.domain.base.BaseModel;
import com.example.literaturesystem.domain.publisher.CNPublisher;

/**
*@author LMR
*@data 2018年1月31日下午9:33:57
*/
@Repository("cnPublisherDao")
public interface ICNPublisherDao {

	 @Select("<script>SELECT  * FROM publishertable2 WHERE 1=1\n" +
	            "<if test=\"publisherID!=null and publisherID!=''\">\n" +
	            "AND PublisherID=#{publisherID}\n" +
	            "</if>\n" +
	            "<if test=\"publisherName2!=null and publisherName2!=''\">\n" +
	            "AND PublisherName2=#{publisherName2}\n" +
	            "</if>\n" +
	            "<if test=\"publisherName1!=null and publisherName1!=''\">\n" +
	            "AND PublisherName1=#{publisherName1}\n" +
	            "</if>\n" +
	            "<if test=\"cityID!=null and cityID!=''\">\n" +
	            "AND CityID=#{cityID}\n" +
	            "</if>\n" +
	            "<if test=\"website!=null and website!=''\">\n" +
	            " AND website=#{website}\n" +
	            "</if>" +
	            "<if test=\"note!=null and note!=''\">\n" +
	            "AND Note=#{note}\n" +
	            "</if>" +
	            "<if test=\"dateTime!=null and dateTime!=''\">\n" +
	            "AND DateTime=#{dateTime}\n" +
	            "</if>" +
	            "</script>")
	List<CNPublisher> query(BaseModel model);
	
	 @Insert("<script>" +
	            " INSERT INTO publishertable2 (PublisherID,PublisherName2, PublisherName1,CityID,website," +
	            " Note, DateTime)" +
	            " VALUES (#{publisherID},#{publisherName2},#{publisherName1},#{cityID},#{website}," +
	            " #{note},#{dateTime})" +
	            "</script>")
	void insert(BaseModel model);
	
	  @Update("<script>" +
	            "UPDATE publishertable2\n" +
	            " <trim prefix=\"SET\" suffixOverrides=\",\">\n" +
	            "<if test=\"publisherName2!=null and publisherName2!=''\">\n" +
	            "PublisherName2=#{publisherName2},\n" +
	            "</if>\n" +
	            "<if test=\"publisherName1!=null and publisherName1!=''\">\n" +
	            "PublisherName1=#{publisherName1},\n" +
	            "</if>\n" +
	            "<if test=\"cityID!=null and cityID!=''\">\n" +
	            "CityID=#{cityID},\n" +
	            "</if>\n" +
	            "<if test=\"website!=null and website!=''\">\n" +
	            "website=#{website},\n" +
	            "</if>" +
	            "<if test=\"note!=null and note!=''\">\n" +
	            "Note=#{note},\n" +
	            "</if>" +
	            "<if test=\"dateTime!=null and dateTime!=''\">\n" +
	            "DateTime=#{dateTime},\n" +
	            "</if>" +
	            " </trim>" +
	            "WHERE PublisherID=#{publisherID}" +
	            "</script>")
	void update(BaseModel model);
}
